{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 模拟梯度下降法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-1.  , -0.95, -0.9 , -0.85, -0.8 , -0.75, -0.7 , -0.65, -0.6 ,\n",
       "       -0.55, -0.5 , -0.45, -0.4 , -0.35, -0.3 , -0.25, -0.2 , -0.15,\n",
       "       -0.1 , -0.05,  0.  ,  0.05,  0.1 ,  0.15,  0.2 ,  0.25,  0.3 ,\n",
       "        0.35,  0.4 ,  0.45,  0.5 ,  0.55,  0.6 ,  0.65,  0.7 ,  0.75,\n",
       "        0.8 ,  0.85,  0.9 ,  0.95,  1.  ,  1.05,  1.1 ,  1.15,  1.2 ,\n",
       "        1.25,  1.3 ,  1.35,  1.4 ,  1.45,  1.5 ,  1.55,  1.6 ,  1.65,\n",
       "        1.7 ,  1.75,  1.8 ,  1.85,  1.9 ,  1.95,  2.  ,  2.05,  2.1 ,\n",
       "        2.15,  2.2 ,  2.25,  2.3 ,  2.35,  2.4 ,  2.45,  2.5 ,  2.55,\n",
       "        2.6 ,  2.65,  2.7 ,  2.75,  2.8 ,  2.85,  2.9 ,  2.95,  3.  ,\n",
       "        3.05,  3.1 ,  3.15,  3.2 ,  3.25,  3.3 ,  3.35,  3.4 ,  3.45,\n",
       "        3.5 ,  3.55,  3.6 ,  3.65,  3.7 ,  3.75,  3.8 ,  3.85,  3.9 ,\n",
       "        3.95,  4.  ,  4.05,  4.1 ,  4.15,  4.2 ,  4.25,  4.3 ,  4.35,\n",
       "        4.4 ,  4.45,  4.5 ,  4.55,  4.6 ,  4.65,  4.7 ,  4.75,  4.8 ,\n",
       "        4.85,  4.9 ,  4.95,  5.  ,  5.05,  5.1 ,  5.15,  5.2 ,  5.25,\n",
       "        5.3 ,  5.35,  5.4 ,  5.45,  5.5 ,  5.55,  5.6 ,  5.65,  5.7 ,\n",
       "        5.75,  5.8 ,  5.85,  5.9 ,  5.95,  6.  ])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot_x = np.linspace(-1., 6., 141)\n",
    "plot_x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_y = (plot_x-2.5)**2 - 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl4ldW5/vHvkzmBJBAykJAREmYIYGRWQVAUUNRaxalqnap1qD+rx9r2dNaetp462zpTRVAQFRVHREVkCiBjAoSQOSQhQBIy7531+4PgoZY5O1l7eD7XlYskbnhvQrxZrLXe9YoxBqWUUp7Pz3YApZRSrqGFrpRSXkILXSmlvIQWulJKeQktdKWU8hJa6Eop5SW00JVSyktooSullJfQQldKKS8R0JUXi46ONqmpqV15SaWU8njr1q3ba4yJOdHrurTQU1NTyc7O7spLKqWUxxORwpN5nU65KKWUl9BCV0opL6GFrpRSXkILXSmlvIQWulJKeQktdKWU8hJa6Eop5SU8otA/2FTO3NUntQ1TKaXcSumBRv78YS6VdU2dfi2PKPQlm8v528fbaXY4bUdRSqlT8sbaYv751S5aHG2dfi2PKPQrz0xif0MrH2+tsB1FKaVOmrPNsCC7mLMyYkjsGdbp1/OIQp+YHk1iz1DeWFtkO4pSSp20r3ZUUV7TxFVnJnXJ9Tyi0P38hCuzk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AB7urAvpnaJKKeUlPGqErpRS6ti00JVSyktooSullJfQQldKKS+hha6UUl5CC10ppbyEFrpSSnkJLXSllPIS/x+DZnALDR7YeQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(plot_x, plot_y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "epsilon = 1e-8\n",
    "eta = 0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.499891109642585\n",
      "-0.99999998814289\n"
     ]
    }
   ],
   "source": [
    "def J(theta):\n",
    "    return (theta-2.5)**2 - 1.\n",
    "\n",
    "def dJ(theta):\n",
    "    return 2*(theta-2.5)\n",
    "\n",
    "theta = 0.0\n",
    "while True:\n",
    "    gradient = dJ(theta)\n",
    "    last_theta = theta\n",
    "    theta = theta - eta * gradient\n",
    "    \n",
    "    if(abs(J(theta) - J(last_theta)) < epsilon):\n",
    "        break\n",
    "    \n",
    "print(theta)\n",
    "print(J(theta))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xd0lVX69vHvnR4gCSUJpEFC7yAGCEUFRLEg1lFQVCygYxmZcfTFaURnRudnmbFXRBlBQRAVFRVFkCIIoUkJNZAKIQRIIaTv948EB5ESOCfZp9yftbLSDjyXGC+2e+9nP2KMQSm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gP7Ae+Mca4ct7ngUeBattB6sgAC0RkjYhMsB3mNNoCecA7tdNZU0SkcX1dzOUKXUS+FZFNJ3lz2ZHucU720EqXHZW5IxFpAnwETDTGFNrOczrGmCpjTG8gFugnIt1tZzoZERkJ7DfGrLGd5SwMMsb0oWZ6834RudB2oFPwA/oArxljzgOOAPW2tuZyTywyxgy3ncEBWUDccZ/HAjmWsngcEfGnpsxnGGPm2s5TV8aYwyKymJr1CldcgB4EjBKRK4AgIFREphtjxlrOdUrGmJza9/tF5GNqpjtdcW0tC8g67v/O5lCPhe5yI3Q3txroICIJIhIAjAbmWc7kEUREqJmHTDXG/Nt2njMRkQgRaVr7cTAwHNhqN9XJGWMeM8bEGmPiqfmZ/c6Vy1xEGotIyLGPgUtxzb8oMcbsAzJFpFPtly4GttTX9dyq0EXkWhHJAgYAX4jI17YzHc8YUwk8AHxNzaLdh8aYzXZTnZqIfACsADqJSJaI3GU702kMAm4FhtVuVVtfO6J0VVHAIhH5iZq/6L8xxrj8dkA30RJYJiIbgFXAF8aYryxnOp0HgRm1Pwu9gSfr60J6p6hSSnkItxqhK6WUOjUtdKWU8hBa6Eop5SG00JVSykNooSullIfQQldKKQ+hha6UUh5CC10ppTzE/wdJFkGExEMQDAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#起点\n",
    "theta = 0.0\n",
    "theta_history = [theta]\n",
    "while True:\n",
    "    gradient = dJ(theta)\n",
    "    last_theta = theta\n",
    "    theta = theta - eta * gradient\n",
    "    theta_history.append(theta)\n",
    "    \n",
    "    if(abs(J(theta) - J(last_theta)) < epsilon):\n",
    "        break\n",
    "\n",
    "plt.plot(plot_x, J(plot_x))\n",
    "plt.plot(np.array(theta_history), J(np.array(theta_history)), color=\"r\", marker='+')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "theta_history = []\n",
    "\n",
    "def gradient_descent(initial_theta, eta, epsilon=1e-8):\n",
    "    theta = initial_theta\n",
    "    theta_history.append(initial_theta)\n",
    "\n",
    "    while True:\n",
    "        gradient = dJ(theta)\n",
    "        last_theta = theta\n",
    "        theta = theta - eta * gradient\n",
    "        theta_history.append(theta)\n",
    "    \n",
    "        if(abs(J(theta) - J(last_theta)) < epsilon):\n",
    "            break\n",
    "            \n",
    "def plot_theta_history():\n",
    "    plt.plot(plot_x, J(plot_x))\n",
    "    plt.plot(np.array(theta_history), J(np.array(theta_history)), color=\"r\", marker='+')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl8VdW9NvDnlzmQCchAQhLCPI9GRgUULCqKrdqKU8VabWuttrX6WntvCfd9P2p7bavV1hYVpYKCUqq2DqhIBJkTZghjyEwGAmSezsl6/zgnEEMmcoa19z7P9/PJJzmbA/sxwsNi7bXXFqUUiIjI/Px0ByAiIvdgoRMRWQQLnYjIIljoREQWwUInIrIIFjoRkUWw0ImILIKFTkRkESx0IiKLCPDmyaKjo1VKSoo3T0lEZHqZmZlnlFIxXb3Pq4WekpKCjIwMb56SiMj0RCS3O+/jlAsRkUWw0ImILIKFTkRkESx0IiKLYKETEVkE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ut05+kupdR5EUmH43qFES9AzwSwUERuBBACIEJEViql7tGcq0NKqSLn51IR+Rcc051GvLZWAKCg1b/O1sKDhW64EbrJ7QIwTEQGiUgQgEUAPtScyRJEROCYh8xSSv1Rd56uiEiMiEQ5vw4FMA/AEb2p2qeU+rVSKlEplQLH79kvjVzmItJbRMJbvgbwLRjzL0oopYoB5IvICOehuQAOe+p8pip0EfmOiBQAmA7gIxFZrztTa0opG4BHAKyH46Ldu0qpQ3pTdUxE3gGwDcAIESkQkQd0Z+rETAD3ArjWuVRtr3NEaVTxADaKyH44/qL/XCll+OWAJhEH4GsR2QdgJ4CPlFKfas7UmZ8BWOX8vTARwDOeOhHvFCUisghTjdCJiKhjLHQiIotgoRMRWQQLnYjIIljoREQWwUInIrIIFjoRkUWw0ImILOL/A0z7Wm7n1XE0AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.01\n",
    "theta_history = []\n",
    "gradient_descent(0, eta)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "424"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl4VdW9PvD3m4EkkAnIQEISEghTGAIYmUUQLA6odWjFqWKttHWotl69tndQ7+3V/no7ONYWFeQ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/AbCJalLcZb7dAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.001\n",
    "theta_history = []\n",
    "gradient_descent(0, eta)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3682"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XdclvX+x/HXlymyFBmCgKCoOFFza6VpWWppwzTT1Mqm5ek0TvVrWOdU57TXqVOWoywtzbZNV2YucCsOQKYsUQFB9vf3xwWpKYpww3WPz/PxuB+M+/a+3pp9/PC9vkNprRFCCGH7nMwOIIQQwjKkoAshhJ2Qgi6EEHZCCroQQtgJKehCCGEnpKALIYSdkIIuhBB2Qgq6EELYCSnoQghhJ1ya8mL+/v46IiKiKS8phBA2Ly4u7rDWOuB8r2vSgh4REUFsbGxTXlIIIWyeUiqlLq+TIRchhLATUtCFEMJOSEEXQgg7IQVdCCHshBR0IYSwE1LQhRDCTkhBF0IIO2ETBf37HZl8srFO0zCFEMKqZBw7wb9/2EtOYUmjX8smCvrynZm8/NM+SisqzY4ihBAX5LPNabz3WyJlFVWNfi2bKOgT+oZxtLicn3Znmx1FCCHqrLJKsyQ2jYs7BBDasnmjX88mCvqQKH9CW3rw2eZUs6MIIUSd/bY/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UUqsx7ldY4w3owcA1SqlRQDPARym1UGs92eRctdJaH6r+mKOU+hJjuNMa762lA+mn/HS2lEYs6FbXodu4zUAHpVSkUsoNmAh8Y3Imu6CUUhjjkPFa61fNznM+SqkApVSL6s89gBHAXnNTnZ3W+jGtdajWOgLj7+xKay7mSilPpZR3zefAFVjnP5RorbOANKVUp+pvDQf2NNb1bKqgK6WuVUqlAwOB75VSP5md6VRa6wpgJvATxk27z7XWu81NVTul1CJgPdBJKZWulLrN7EznMBiYAlxWPVVtW3VHaa2CgVVKqR0Y/9D/orW2+umANiII+F0ptR3YBHyvtf7R5Eznch/wSfXfhZ7A8411IVkpKoQQdsKmOnQhhBC1k4IuhBB2Qgq6EELYCSnoQghhJ6SgCyGEnZCCLoQQdkIKuhBC2Akp6EIIYSf+H2Hr0bZtgKikAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.8\n",
    "theta_history = []\n",
    "gradient_descent(0, eta)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "ename": "OverflowError",
     "evalue": "(34, 'Result too large')",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mOverflowError\u001b[0m                             Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-17-3ec2a66aa12d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0meta\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m1.1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mtheta_history\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mgradient_descent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0meta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-11-145c57b22fc1>\u001b[0m in \u001b[0;36mgradient_descent\u001b[1;34m(initial_theta, eta, epsilon)\u001b[0m\n\u001b[0;32m     11\u001b[0m         \u001b[0mtheta_history\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     12\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m         \u001b[1;32mif\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mJ\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mJ\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlast_theta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mepsilon\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     14\u001b[0m             \u001b[1;32mbreak\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     15\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-8-e94a592ba905>\u001b[0m in \u001b[0;36mJ\u001b[1;34m(theta)\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mJ\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m2.5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m \u001b[1;33m-\u001b[0m \u001b[1;36m1.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdJ\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m2.5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mOverflowError\u001b[0m: (34, 'Result too large')"
     ]
    }
   ],
   "source": [
    "eta = 1.1\n",
    "theta_history = []\n",
    "gradient_descent(0, eta)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def J(theta):\n",
    "    try:\n",
    "        return (theta-2.5)**2 - 1.\n",
    "    except:\n",
    "        return float('inf')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def gradient_descent(initial_theta, eta, n_iters = 1e4, epsilon=1e-8):\n",
    "    \n",
    "    theta = initial_theta\n",
    "    i_iter = 0\n",
    "    theta_history.append(initial_theta)\n",
    "\n",
    "    while i_iter < n_iters:\n",
    "        gradient = dJ(theta)\n",
    "        last_theta = theta\n",
    "        theta = theta - eta * gradient\n",
    "        theta_history.append(theta)\n",
    "    \n",
    "        if(abs(J(theta) - J(last_theta)) < epsilon):\n",
    "            break\n",
    "            \n",
    "        i_iter += 1\n",
    "        \n",
    "    return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eta = 1.1\n",
    "theta_history = []\n",
    "gradient_descent(0, eta)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "eta = 1.1\n",
    "theta_history = []\n",
    "gradient_descent(0, eta, n_iters=10)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
